﻿<Page
    x:Name="PageRoot"
    x:Class="InputsExample.InputsPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:InputsExample"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Back button and page title -->
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="BackButton" Margin="39,59,39,0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}"
                        Style="{StaticResource NavigationBackButtonNormalStyle}"
                        VerticalAlignment="Top"
                        AutomationProperties.Name="Back"
                        AutomationProperties.AutomationId="BackButton"
                        AutomationProperties.ItemType="Navigation Button"/>
            <TextBlock x:Name="PageTitle" Text="{StaticResource AppName}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1" 
                        IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,30,40"/>
        </Grid>

        <Grid Grid.Row="1" Grid.ColumnSpan="2" Margin="116,0,116,46" Background="Transparent">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.Resources>
                <Style TargetType="TextBlock" BasedOn="{StaticResource BodyTextBlockStyle}">
                    <Setter Property="Margin" Value="5,0"/>
                </Style>
                <Style TargetType="TextBlock" BasedOn="{StaticResource BodyTextBlockStyle}" x:Key="BlockHeaderTextBlockStyle">
                    <Setter Property="Margin" Value="5,5,5,0"/>
                    <Setter Property="FontWeight" Value="Bold"></Setter>
                </Style>
            </Grid.Resources>
            <Grid Grid.Column="0" Grid.Row="0" Width="320" Margin="0,0,80,0"  DataContext="{Binding InputSettings}" d:DataContext="{d:DesignInstance Type=local:InputSettings, IsDesignTimeCreatable=true}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <TextBlock Grid.Row="0" Grid.Column="0" Text="Animation On:"/>
                <CheckBox Grid.Row="0" Grid.Column="1" IsChecked="{Binding IsAnimationOn, Mode=TwoWay}"/>

                <TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="9" Text="Pointers:" Style="{StaticResource BlockHeaderTextBlockStyle}"/>
                <TextBlock Grid.Row="2" Grid.Column="0" Text="Integrated Devices Only:"/>
                <CheckBox Grid.Row="2" Grid.Column="1" IsChecked="{Binding PointerIntegratedDevicesOnly, Mode=TwoWay}"/>

                <TextBlock Grid.Row="3" Grid.Column="0" Text="Mouse:"/>
                <CheckBox Grid.Row="3" Grid.Column="1" IsEnabled="{Binding IsMouseAvailable}" IsChecked="{Binding PointerSupportMouse, Mode=TwoWay}"/>
                <Button Grid.Row="3" Grid.Column="2" IsEnabled="{Binding IsMouseAvailable}" Content="Details" HorizontalAlignment="Stretch" Click="HandleMouseDetailsClick"/>
                <TextBlock Grid.Row="4" Grid.Column="0" Text="Touch:"/>
                <CheckBox Grid.Row="4" Grid.Column="1" IsEnabled="{Binding IsTouchAvailable}" IsChecked="{Binding PointerSupportTouch, Mode=TwoWay}"/>
                <Button Grid.Row="4" Grid.Column="2" IsEnabled="{Binding IsTouchAvailable}" Content="Details" HorizontalAlignment="Stretch" Click="HandleTouchDetailsClick"/>
                <TextBlock Grid.Row="5" Grid.Column="0" Text="Pen:"/>
                <CheckBox Grid.Row="5" Grid.Column="1" IsEnabled="{Binding IsPenAvailable}" IsChecked="{Binding PointerSupportPen, Mode=TwoWay}"/>

                <TextBlock Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="9" Text="Manipulations:" Style="{StaticResource BlockHeaderTextBlockStyle}"/>
                <TextBlock Grid.Row="7" Grid.Column="0" Text="Translate:"/>
                <CheckBox Grid.Row="7" Grid.Column="1" IsChecked="{Binding ManipulationTransform, Mode=TwoWay}"/>
                <CheckBox Grid.Row="7" Grid.Column="2" Content="Use Inertia" IsEnabled="{Binding ManipulationTransform}" IsChecked="{Binding ManipulationTransformInertia, Mode=TwoWay}"/>
                <TextBlock Grid.Row="8" Grid.Column="0" Text="Rotate:"/>
                <CheckBox Grid.Row="8" Grid.Column="1" IsChecked="{Binding ManipulationRotation, Mode=TwoWay}"/>
                <CheckBox Grid.Row="8" Grid.Column="2" Content="Use Inertia" IsEnabled="{Binding ManipulationRotation}" IsChecked="{Binding ManipulationRotationInertia, Mode=TwoWay}"/>
                <TextBlock Grid.Row="9" Grid.Column="0" Text="Scale"/>
                <CheckBox Grid.Row="9" Grid.Column="1" IsChecked="{Binding ManipulationScaling, Mode=TwoWay}"/>
                <CheckBox Grid.Row="9" Grid.Column="2" Content="Use Inertia" IsEnabled="{Binding ManipulationScaling}" IsChecked="{Binding ManipulationScalingInertia, Mode=TwoWay}"/>

                <TextBlock Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="9" Text="Gestures:" Style="{StaticResource BlockHeaderTextBlockStyle}"/>
                <TextBlock Grid.Row="11" Grid.Column="0" Text="Tap Enabled:"/>
                <CheckBox Grid.Row="11" Grid.Column="1" IsChecked="{Binding TapEnabled, Mode=TwoWay}"/>
                <TextBlock Grid.Row="12" Grid.Column="0" Text="Double-Tap Enabled:"/>
                <CheckBox Grid.Row="12" Grid.Column="1" IsChecked="{Binding DoubleTapEnabled, Mode=TwoWay}"/>
                <TextBlock Grid.Row="13" Grid.Column="0" Text="Right-Tap Enabled:"/>
                <CheckBox Grid.Row="13" Grid.Column="1" IsChecked="{Binding RightTapEnabled, Mode=TwoWay}"/>
                <TextBlock Grid.Row="14" Grid.Column="0" Text="Hold Enabled:"/>
                <CheckBox Grid.Row="14" Grid.Column="1" IsChecked="{Binding HoldingEnabled, Mode=TwoWay}"/>

                <TextBlock Grid.Row="15" Grid.Column="0" Text="Keyboard:" Style="{StaticResource BlockHeaderTextBlockStyle}"/>
                <Button Grid.Row="15" Grid.Column="2" Content="Details" HorizontalAlignment="Stretch" Click="HandleKeyboardDetailsClick"/>
            </Grid>
            <Grid Grid.Column="0" Grid.Row="1">
                <StackPanel>
                    <Border Background="{ThemeResource ButtonBackgroundThemeBrush}" Margin="3" Padding="5,0,5,10">
                        <TextBlock Text="Tap Here for Pointer Point Details" FontWeight="SemiBold" PointerPressed="HandlePointerDetailsPressed" TextAlignment="Center">
                            <FlyoutBase.AttachedFlyout>
                                <Flyout Placement="Right">
                                    <Grid Height="300" Width="300">
                                        <ScrollViewer>
                                            <ItemsControl ItemsSource="{Binding PointerPointValues}"/>
                                        </ScrollViewer>
                                    </Grid>
                                </Flyout>
                            </FlyoutBase.AttachedFlyout>
                        </TextBlock>
                    </Border>
                    <Button Content="Add Ball (B)" HorizontalAlignment="Stretch" Click="HandleAddBallClick" AutomationProperties.AccessKey="B" AutomationProperties.AcceleratorKey="B"/>
                    <Button Content="Add Square (S)" HorizontalAlignment="Stretch" Click="HandleAddSquareClick"/>
                </StackPanel>
            </Grid>
            <Grid Grid.Column="1" Grid.Row="0" Grid.RowSpan="2">
                <ItemsControl x:Name="ShapePanel" ItemsSource="{Binding Shapes}" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <Canvas/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplateSelector>
                        <local:ShapeTemplateSelector>
                            <local:ShapeTemplateSelector.SquareTemplate>
                                <DataTemplate>
                                    <local:SquareControl/>
                                </DataTemplate>
                            </local:ShapeTemplateSelector.SquareTemplate>
                            <local:ShapeTemplateSelector.EllipseTemplate>
                                <DataTemplate>
                                    <local:BallControl/>
                                </DataTemplate>
                            </local:ShapeTemplateSelector.EllipseTemplate>
                        </local:ShapeTemplateSelector>
                    </ItemsControl.ItemTemplateSelector>
                </ItemsControl>
            </Grid>
        </Grid>
    </Grid>
</Page>
